import axios from 'axios'
import { BASEURL } from '../constants'
const uploadInstance = axios.create({
  baseURL: BASEURL,
})

uploadInstance.interceptors.request.use(
  function (config) {
    // 在发送请求之前做些什么
    config.headers['Content-Type'] = 'multipart/form-data'
    config.headers['Authorization'] =
      'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImlhdCI6MTY2MDI3NDQyMywiZXhwIjoxNjYwMzYwODIzfQ.58QNV_WqVZ2I7U4hrO5IAMMustUxp0drbyG1XmwWsJY'
    console.log(config)
    return config
  },
  function (error) {
    // 对请求错误做些什么
    return Promise.reject(error)
  }
)

export function upload(data) {
  return uploadInstance.post('/upload/img', data)
}
